import React from 'react'
import { useState,useRef } from 'react'
import Child from './Child'


export default function Parent() {
    const [list,setList] = useState(['html','css','js'])
    const inputRef = useRef(null)

    const handler =()=>{
        setList([...list,inputRef.current.value])
    }
    return (
    <div>
        <div className="hd">
            <input ref={inputRef} type="text" />
            <button onClick={handler}>确认</button>
        </div>
        <Child list={list} />
    </div>
  )
}
